﻿using System.Collections.Generic;

namespace Cms.Domain.Comparers
{
    public class ScheduledPublishingComparer : IComparer<ScheduledPublishing>
    {
        private readonly SortDirection _sortDirection;

        public ScheduledPublishingComparer(SortDirection sortDirection)
        {
            _sortDirection = sortDirection;
        }

        #region IComparer<ScheduledPublishing> Members

        public int Compare(ScheduledPublishing x, ScheduledPublishing y)
        {
            int result = string.Compare(x.Timestamp, y.Timestamp);
            return _sortDirection == SortDirection.Ascending ? result : result * -1;
        }

        #endregion
    }
}